package com.example.module_home.model

import com.example.lib_net.HttpManger
import com.example.lib_net.RetrofitUtils
import com.example.module_home.api.HomeApiServer
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import javax.inject.Qualifier
import javax.inject.Singleton

@Qualifier//声明依赖注入，用于区分多个实例
@Retention(AnnotationRetention.BINARY)
annotation class Home{

}

@Module
@InstallIn(SingletonComponent::class)
object NetworkModule {
    @Home
    @Provides
    @Singleton
    fun provideRetrofit():Retrofit{
        return HttpManger.getRetrofit()
    }

//    @Home
//    @Provides
//    @Singleton
//    fun provideHomeApiService(@Home retrofit: Retrofit):HomeApiServer{
//        return retrofit.create(HomeApiServer::class.java)
//    }

    @Provides
    @Singleton
    fun provideDeviceApiService(@Home retrofit: Retrofit):HomeApiServer{
        return retrofit.create(HomeApiServer::class.java)
    }

//    @Home
//    @Provides
//    @Singleton
//    fun provideHouseApiService(@Home retrofit: Retrofit):HomeApiServer{
//        return retrofit.create(HomeApiServer::class.java)
//    }

}